﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PhotoGallery.DLL;
using PhotoGallery.Model;
namespace PhotoGallery.BLL
{
    /*修改个人资料*/
    public class UserAction
    {
        UserDataAccess uda = new UserDataAccess();

        /*修改昵称*/
        public void changenickname(string uid,string nickname) 
        {
            User u = uda.searchUserById(uid);
            u.Nickname = nickname;
            uda.modifyUser(uid,u);
        }

        /*修改密码*/
        public void changePwd(string uid,string password)
        {
            User u = uda.searchUserById(uid);
            u.Password = password;
            uda.modifyUser(uid, u);
        }
        /*根据用户id取得用户信息*/
        public User getUserbyId(string uid) 
        {
            User u = uda.searchUserById(uid);
            return u;
        }
        /*获取用户的头像*/
        public Picture getAvatorById(string uid) 
        {
            PictureDataAccess pda = new PictureDataAccess();
            AlbumsDataAccess ada = new AlbumsDataAccess();
            //取得某人的全部相册
            List<Albums> list=ada.searchAlbumByUid(uid);
            foreach(Albums a in list)
            {
                if (a.Title == "头像相册" && a.Desp == "头像相册")//有头像相册
                {
                    return pda.getCoverPicbyAlbumId(a.Aid);
                }
                else //不是头像相册
                {

                }
            }
            return null;
        }
    }
}
